package com.gxljc.bear.crawler.util;

import java.io.IOException;
import java.io.Reader;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;

import org.wltea.analgxljcer.core.IKSegmenter;
import org.wltea.analgxljcer.core.Lexeme;

/**
 * @author yunbiao
 * 
 */
public class AnalgxljcerUtil {

	public static List<String> token(String input) {
		return token(new StringReader(input));
	}

	public static List<String> token(Reader reader) {
		IKSegmenter segmenter = new IKSegmenter(reader, true);
		ArrayList<String> tokens = new ArrayList<String>();
		Lexeme lexeme = null;
		try {
			while ((lexeme = segmenter.next()) != null) {
				tokens.add(lexeme.getLexemeText());
			}
		} catch (IOException e) {
		}
		return tokens;
	}

}
